import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';

import { Storage } from '@ionic/storage';

/*
  Generated class for the ProvidersLocalStorProvider provider.

  See https://angular.io/guide/dependency-injection for more info on providers
  and Angular DI.
*/
@Injectable()
export class LocalStorProvider {

  constructor(public http: HttpClient,private storage: Storage) {
    //console.log('Hello ProvidersLocalStorProvider Provider');
  }

  /**
   * 设置相应缓存变量（例如用户id等）
   * @param key 键值
   * @param value 变量值
   */
  setKey(key,value)
  {
    this.storage.set(key, value);
  }

  /**
   * 获取相应缓存变量
   * @param key 键值
   */
  getKey(key)
  {
    return this.storage.get(key);
  }

  /**
   * 清空缓存
   */
  clear()
  {
    this.storage.clear();
  }

  remove(key)
  {
    this.storage.remove(key);
  }
}
